<?php

class PlaceMarkDTO {
	
	const DUMMY_TRIP_ID = 1;
	
	public $latitude;
	public $longitude;
	public $name;
	public $description;
	public $fileUrl;
	public $type;
	public $created;
	public $modified;
	public $tripElements;
	
	public function getPresentName() {
		return substr($this->name, 0, 20);
	}
	
	/**
	 * Add trip element if it's new.
	 * 
	 * @param $elementLabel
	 */
	public function addTripElement($elementLabel) {
		$elementLabel = addslashes(strtoupper(trim($elementLabel)));
		if (!isset($this->tripElements) || !is_array($this->tripElements)) {
			$this->tripElements = array();
			$tripElement = new TripElement();
			$tripElement->trip_id = self::DUMMY_TRIP_ID;
			$tripElement->label = $elementLabel;
			$this->tripElements[$elementLabel] = $tripElement;
		} else {
			foreach($this->tripElements as $tripElement) {
				if ($tripElement->label == $elementLabel) {
					continue;
				}
				$temp = new TripElement();
                $temp->trip_id = self::DUMMY_TRIP_ID;
                $temp->label = $elementLabel;
				$this->tripElements[$elementLabel] = $temp;
			}
		}
	}
}
?>